#include<cstdio>
using namespace std;
int n,q,a[10000],i,j,ans[10000],x,y,z;
int main()
{
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	scanf("%d%d",&n,&q);
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=i;j++)
		if(a[j]<=a[i])
		ans[i]++;
		for(j=i+1;j<=n;j++)
		if(a[j]<a[i])
		ans[i]++;
	}
	for(i=1;i<=q;i++)
	{
		scanf("%d",&x);
		if(x==1)
		{
			scanf("%d%d",&y,&z);
			ans[y]=1;
			for(j=1;j<y;j++)
			if(a[j]<=z)
			ans[y]++;
			for(j=y+1;j<=n;j++)
			if(a[j]<z)
			ans[y]++;
			for(j=1;j<y;j++)
			if(a[j]>a[y]&&a[j]<=z)
			ans[j]--;
			else if(a[j]<=a[y]&&a[j]>z)
			ans[j]++;
			for(j=y+1;j<=n;j++)
			if(a[j]>=a[y]&&a[j]<z)
			ans[j]--;
			else if(a[j]<a[y]&&a[j]>=z)
			ans[j]++;
			a[y]=z;
		}
		else
		{
			scanf("%d",&y);
			printf("%d\n",ans[y]);
		}
	}
	return 0;
}
